<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>发布资讯</title>
		<script src="/static/skin.js"></script>
		<script src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script>
		<script src="/static/basic/plugins/query/jquery.query.js"></script>
		<script src="/static/basic/plugins/easyui/jquery.easyui.min.js"></script>
		<script src="/static/init.js"></script>
		<script src="/static/basic/plugins/easyui/locale/easyui-lang-zh_CN.js"></script>
		<link rel="stylesheet" href="/static/basic/plugins/easyui/themes/icon.css" >
		<script charset="utf-8" src="/static/basic/plugins/kindeditor-4.1.1/kindeditor.js"></script>
		<script charset="utf-8" src="/static/basic/plugins/kindeditor-4.1.1/lang/zh_CN.js"></script>
		<script src="/static/basic/plugins/plupload-2.1.9/js/plupload.full.min.js"></script>
		<script src="/static/basic/plugins/plupload-2.1.9/js/i18n/zh_CN.js"></script>
		<script charset="utf-8" src="/static/plupload-v0.2.js?v=2"></script>
		<style type="text/css">
			table.ets td input{width:270px}
		</style>
	</head>
	<body>
		<div id="main-layout" class="easyui-layout" data-options="fit:true" style="height:650px;width:100%;">
			<div region="center" style="height:100%;width:100%">
				<div data-options="fit:true,border:false" class="easyui-panel" title="">
					<div data-options="fit:true,border:false" class="easyui-panel" style="padding-top:14px;padding-left:0px;">
						<form id="form39" method="post">
							<input id="id" type="hidden" name="id"/>
							<table class="ets" style="height:100%;width:900px;padding-left:0px">
								<!-- <tr>
									<td>关键字:</td>
									<td><input type="text" name="news_keywords" class="easyui-textbox"></input></td>
								</tr>
								<tr>
									<td>创建时间:</td>
									<td><input type="text" name="create_time" class="easyui-textbox"></input></td>
								</tr>
								<tr>
									<td>创建人:</td>
									<td><input type="text" name="creator_name" class="easyui-textbox"></input></td>
								</tr>
								<tr>
									<td>创建人id:</td>
									<td><input type="text" name="creator_id" class="easyui-textbox"></input></td>
								</tr>
								<tr>
									<td>立即发布:</td>
									<td><input type="text" name="is_release" class="easyui-textbox"></input></td>
								</tr>
								<tr>
									<td>:</td>
									<td><input type="text" name="news_source" class="easyui-textbox"></input></td>
								</tr>
								<tr>
									<td>资讯内容:</td>
									<td><input type="text" name="news_content" class="easyui-textbox"></input></td>
								</tr>
								<tr>
									<td>缩略图:</td>
									<td><input type="text" name="news_picture" class="easyui-textbox"></input></td>
								</tr>
								<tr>
									<td>摘要:</td>
									<td><input type="text" name="news_abstract" class="easyui-textbox"></input></td>
								</tr>
								
								<tr>
									<td>资讯类型:</td>
									<td><input type="text" name="new_class_id" class="easyui-textbox"></input></td>
								</tr> -->
								<tr>
									<td>标题</td>
									<td><input type="text" name="news_title" class="easyui-textbox"></input></td>
								</tr>
								<tr>
									<td></td>
									<td>
									<textarea name="news_content" style="width:640px;height:640px;visibility:hidden;"></textarea>
									<script>
									KindEditor.ready(function(K){
										editor1 = K.create('textarea[name="news_content"]', {
									           allowFileManager : true,
									           extraFileUploadParams : {
									                     file_id:11,
									                     file_group_id:2
									              }
										});
									});
									</script>
									</td>
								</tr>
							</table>
						</form>
					</div>

				</div>
			</div>
			<div region="north" data-options="split:false,border:false" style="width:100%;height:40px;">
				<div style="width:100%;height:100%">
					<div data-options="fit:true,border:false" title="" style="padding:5px">
						<a href="javascript:void(0)" id="saveButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-save'">保存</a>
					</div>
				</div>
			</div>
		</div>
<script>
var id = $.query.get('id');
//document ready
$(function(){
	/*KindEditor.ready(function(K) {
		editor = K.create('textarea[name="text"]', {
			uploadJson : '/static/basic/plugins/kindeditor-4.1.1/jsp/upload_json.jsp',
          fileManagerJson : '/static/basic/plugins/kindeditor-4.1.1/jsp/file_manager_json.jsp',
          allowFileManager : true
		});
	});*/
	$('#saveButton').bind('click', save);//添加按钮绑定事件
	if(id){
		loadForm();
	}
});

function loadForm(){
	$._post("/authenticated/ajax/map/select_get_sys_pub_news",JSON.stringify({id:id}),function(result){
		if(result.success){
			$('#form39').form('load',result.data);
			editor1.html(result.data.news_content);
			//$('#editForm-logo_img').attr("src",result.data.logo);
		}else{
			$.messager.alert("提示", result.message);
		}
	});
}

function save(){
	if(editor1){
		editor1.sync();
	}
	var formObject=$("#form39").serializeObject();
	$.ajax({
		url: "/authenticated/mnews/save",
		data:JSON.stringify(formObject),
		success: function(result){
			if(result.success){
				id=result.data;
				$("#id").val(id);
				$.messager.alert("提示", "保存成功！");
			}else{
				$.messager.alert("提示", "保存失败！");
			}
		},
		error: function(){
			$.messager.alert("提示", "服务器响应异常！");
		}
	});
}

</script>
	</body>
</html>